package com.socodethis.spaceex;

import javax.swing.text.Style;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle;
import com.badlogic.gdx.scenes.scene2d.ui.ClickListener;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.scenes.scene2d.ui.Window.WindowStyle;
import com.badlogic.gdx.scenes.scene2d.ui.tablelayout.Table;
import com.socodethis.spaceex.gamescreen.GameScreen;
import com.socodethis.spaceex.mainmenuscreen.actors.MenuButton;
import com.socodethis.spaceex.utils.ScreenSize;

public class OptionsScreen implements Screen {
private Stage stage;
private Table window;

private static final float BUTTON_WIDTH = 300f;
private static final float BUTTON_HEIGHT = 60f;
private static final float BUTTON_SPACING = 10f;

public OptionsScreen(final customGame game){
	stage = new Stage(SpaceExConstants.SCREEN_WIDTH,SpaceExConstants.SCREEN_HEIGHT,true);
	Gdx.input.setInputProcessor(stage);
	window = new Table("window");
	window.width = stage.width();
    window.height = stage.height();
    window.x = 0;
    window.y = 0;
    window.debug();
	Skin skin = new Skin(Gdx.files.internal("skins/button.json"), Gdx.files.internal("default_button.png"));
	LabelStyle lStyle = new LabelStyle();
	lStyle.font = new BitmapFont(Gdx.files.internal("skins/default.fnt"),false);
	lStyle.fontColor = Color.GRAY;
	Label label = new Label("Options Menu", lStyle);
	label.x = ( ( stage.width() - label.width ) / 2 );
	lStyle.fontColor = Color.MAGENTA;
	Label label2 = new Label("Choose Nav Controls", lStyle);
	label2.x = ( ( stage.width() - label2.width ) / 2 );
    TextButton PathFinder = new TextButton("PathFinder",skin.getStyle(TextButtonStyle.class));
    PathFinder.width((int) (stage.width()/4));
    TextButton Navigator = new TextButton("Navigator",skin.getStyle(TextButtonStyle.class));
    Navigator.width((int) (stage.width()/4));
    
    PathFinder.setClickListener(new ClickListener() {

		@Override
		public void click(Actor actor, float x, float y) {
			// TODO Auto-generated method stub
			game.setPathFinder(true);
			//game.setScreen();
			game.setScreen(new GameScreen(game));
			//game.setScreen(game.getScreen());
			//game.dispose();
			//game.getScreen().hide();
			//game.setScreen(game.getGScreen());   
		}

    });
    
    Navigator.setClickListener(new ClickListener() {

		@Override
		public void click(Actor actor, float x, float y) {
			// TODO Auto-generated method stub
			game.setPathFinder(false);
			//game.setScreen();
			//game.setScreen(game.getScreen());
			//game.getScreen().hide();

			game.setScreen(new GameScreen(game));
			//game.setScreen(game.getGScreen());   
		}

    });
    
    
    Table mContainer = new Table("menu");
    //mContainer.setFillParent(true);
    //mContainer.width((int) window.width);
    //mContainer.height((int) window.height);
    //mContainer.row().fill(true, true).expand(true, true).pad(0, 0, 20, 0).center();
    mContainer.row();
    mContainer.add(label);
    mContainer.row();//.fill(true, true).expand(true, true).pad(0, 0, 20, 0).center();
    mContainer.add(label2);
    mContainer.row();//.expand(true, true).pad(0, 0, 10, 0).center();
    mContainer.add(PathFinder);
    //mContainer.pad(10);
    //container.row().fill(true, true).expand(true, true).pad(10, 0, 10, 0);
    mContainer.add(Navigator);
    //mContainer.center().top();
    window.add(mContainer);
    stage.addActor(window);
    
	//Skin skin = new Skin(Gdx.files.internal("skins/button.json"), Gdx.files.internal("default_button.png"));
	//TextButton tButt = new TextButton("Arrows", null);
	//TextButton arrowButton = new TextButton("myButton", skin.getStyle(TextButtonStyle.class));
	
	//Window window = new Window("MyWindow", skin.getStyle(WindowStyle.class));
	
	
	//MenuButton arrowButton = new MenuButton(((int)ScreenSize.getScaledWidth(texPlay.getWidth())/2),
	//		((int)ScreenSize.getScaledHeight(texPlay.getHeight())*2),texPlay);
	
	//MenuButton clickButton = new MenuButton(((int)ScreenSize.getScaledWidth(texPlay.getWidth())/2),
	//		((int)ScreenSize.getScaledHeight(texPlay.getHeight())*2)-100,texPlay);

    //stage.addActor( arrowButton );
    //stage.addActor( clickButton );

}
@Override
public void render(float delta) {
	Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
	Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

	stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
	stage.draw();
	//Table.drawDebug(stage);
	
}
@Override
public void resize(int width, int height) {
	// TODO Auto-generated method stub
	
}
@Override
public void show() {
	// TODO Auto-generated method stub
	
}
@Override
public void hide() {
	// TODO Auto-generated method stub
	
}
@Override
public void pause() {
	// TODO Auto-generated method stub
	
}
@Override
public void resume() {
	// TODO Auto-generated method stub
	
}
@Override
public void dispose() {
	// TODO Auto-generated method stub
	
}
}